var raycloud = new Object();
raycloud.util = new Object();
if (raycloud == null) {
	raycloud = new Object();
}
if (raycloud.util == null) {
	raycloud.util = new Object();
}

// 让select选中相应的option
raycloud.util.selectValueMatcher = function(_select_id, _value) {
	var _select_obj = document.getElementById(_select_id);
	var _select_options = _select_obj.options;
	for ( var int = 0; int < _select_options.length; int++) {
		if (_value == _select_options[int].value) {
			_select_obj.selectedIndex = int;
		}
	}
};

raycloud.util.isNotBlank = function(str) {
	if (str == null) {
		return false;
	}
	if (str == 'null') {
		return false;
	}
	if ($.trim(str).length == 0) {
		return false;
	}
	return true;
};

raycloud.util.isInteger = function(str) {
	pattern = /^[0-9]*$/;
	return pattern.test(str);
};

raycloud.util.isNumber = function(s) {
	if (s != null && s != "") {
		return !isNaN(s);
	}
	return false;
};

raycloud.util.getNowDateStr = function() {
	today = new Date();

	var todayStr = today.getYear() + "-";
	if (today.getMonth() < 10) {
		todayStr = todayStr + "0" + today.getMonth();
	} else {
		todayStr = todayStr + today.getMonth();
	}

	if (today.getDay() < 10) {
		todayStr = todayStr + "-0" + today.getDay();
	} else {
		todayStr = todayStr + today.getDay();
	}
	todayStr = todayStr + " ";

	if (today.getHours() < 10) {
		todayStr = todayStr + today.getHours();
	} else {
		todayStr = todayStr + today.getHours();
	}

	if (today.getMinutes() < 10) {
		todayStr = todayStr + ":0" + today.getMinutes();
	} else {
		todayStr = todayStr + ":" + today.getMinutes();
	}
	todayStr = todayStr + ":00";
	return todayStr;
};

raycloud.util.dialog = function(div_id, width, height, title, content, modal) {
	$("#" + div_id).html(content);
	$("#" + div_id).dialog({
		title : title,
		width : width,
		height : height,
		modal : modal,
		position:'center',
		close : function(event, ui) {
			$(this).dialog("destroy");
		},
		buttons : {
			'确定' : function() {
				$(this).dialog("destroy");
			}
		}
	});
	$("#" + div_id).dialog('open');
};

raycloud.util.dialogWithConfirmFunction = function(div_id, width, height, title, content, modal, confirmFunction) {
	$("#" + div_id).html(content);
	$("#" + div_id).dialog({
		title : title,
		width : width,
		height : height,
		modal : modal,
		position:'center',
		close : function(event, ui) {
			$(this).dialog("destroy");
		},
		buttons : {
			'确定' : function() {
				$(this).dialog("destroy");
				confirmFunction();
			}
		}
	});
	$("#" + div_id).dialog('open');
};

raycloud.util.dialogNoBtns = function(div_id, width, height, title, content, modal){
	$("#" + div_id).html(content);
	$("#" + div_id).dialog({
		title : title,
		width : width,
		height : height,
		modal : modal,
		close : function(event, ui) {
			$(this).dialog("destroy");
		}
	});
	$("#" + div_id).dialog('open');
};

raycloud.util.closeDialog = function(div_id){
	$("#" + div_id).dialog("close");
};

/**
 * 让select选中相应的option
 */
raycloud.util.setSelectValue = function(selectId, value) {
	var selectObj = document.getElementById(selectId);
	var selectOps = selectObj.options;
	for(var i = 0; i < selectOps.length; i++) {
		if(selectOps[i].value == value) {
			selectObj.selectedIndex = i;
			return;
		}
	}
};